<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        window.onload=function()
        {
            function * gen(str)
            {
                //给gen()传入一个参数
                console.log(str)
                let one=yield 111;
                console.log(one);
                let two=yield 222;
                console.log(two);
                let three=yield 333;
                console.log(three);
            }
            //执行获取迭代器对象
            let iterator=gen("AAA");
            console.log(iterator.next());
            console.log(iterator.next("BBB"));
            console.log(iterator.next("CCC"));
            console.log(iterator.next("DDD"));
            //next方法可以传入实参，并且可以输出
            /*
            for(let i=0;;i++)
            {
                var next=iterator.next();
                if(next.done===false)
                {
                    console.log(next.value);
                }
                else
                {
                    break;
                }
            }
            */
        };
    </script>
</head>
<body>
    
</body>
</html>